home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / serial / dim-1.000 / dim-1 / dim-1.03 / src / reinit.c < prev    next >
C/C++ Source or Header  |  1993-12-27  |  646b  |  34 lines

  1. #include "dim.h"
  2.  
  3. void reinit (int kill_init)
  4. {
  5.     FILE
  6.         *pslist;
  7.     char
  8.         buf [256];
  9.     int
  10.         pid;
  11.         
  12.     if (! (pslist = popen (PSCMD, "r")) )\
  13.         error ("can't get processes list\n");
  14.         
  15.     while (fgets (buf, 255, pslist))
  16.     if (strstr (buf, GETTYSTRING))
  17.         if (! sscanf (buf, " %d", &pid))
  18.             error ("can't find PID in ps-output \"%s\"\n", buf);
  19.         else if (kill (pid, SIGHUP))
  20.             error ("can't kill (%d,SIGHUP) in \"%s\"\n", pid, buf);
  21.                 
  22.     pclose (pslist);
  23.         
  24.     if (kill_init)
  25.     {
  26.         if (kill (PID_INIT, SIGHUP))
  27.             error ("can't restart init\n");
  28.  
  29.         printf("init restarted\n");
  30.     }
  31.     
  32. }
  33.     
  34.